home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / csim / source.lha / source / C++SIM / TestSet.cc < prev    next >
C/C++ Source or Header  |  1993-06-14  |  699b  |  52 lines

  1. /*
  2.  * Copyright (C) 1993
  3.  *
  4.  * Department of Computing Science,
  5.  * The University,
  6.  * Newcastle upon Tyne,
  7.  * UK.
  8.  */
  9.  
  10. #ifndef SET_H_
  11. #include "Set.h"
  12. #endif
  13.  
  14. #ifndef ELEMENT_H_
  15. #include "Element.h"
  16. #endif
  17.  
  18. #include <iostream.h>
  19.  
  20.  
  21. int main ()
  22. {
  23.     Set S1, S2;
  24.     Set *S3 = 0;
  25.     Element* E = 0;
  26.     
  27.     for (int i = 0; i < 10; i++)
  28.     {
  29.     E = new Element(i);
  30.     E->InTo(&S1);
  31.     }
  32.     
  33.     for (int j = 8; j < 14; j++)
  34.     {
  35.     E = new Element(j);
  36.     E->InTo(&S2);
  37.     }
  38.  
  39.     S3 = S1.Intersect(&S2);
  40.     
  41.     E = (Element*) S3->First();
  42.     
  43.     cout << "Intersection is:" << endl;
  44.     while (E)
  45.     {
  46.     cout << "value: " << E->GetValue() << endl;
  47.     E = (Element*) E->Suc();
  48.     }
  49.     
  50.     return 0;
  51. }
  52.